let text = document.querySelector("#text");//为啥是#
let add_btn = document.querySelector(".add");
let delete_btns = document.querySelector("ul li button");
let list = document.querySelector(".list");



list.addEventListener("click", (e) => {
  if (e.target.nodeName == "BUTTON") {
    list.removeChild(e.target.parentElement);
  }
});
add_btn.addEventListener("click", () => {
  const { value } = text;
  if (value) {
    text.value = "";
    let li = document.createElement("li");
    let btn = document.createElement("button");
    let newContent = document.createTextNode(value);
    let btn_text = document.createTextNode("删除");
    btn.appendChild(btn_text);
    li.appendChild(newContent);
    li.appendChild(btn);
    list.appendChild(li);
  } else alert("输入为空，请重新输入");
});